#pragma once
/**
 * @file delete.cpp
 * @author mixinju@outlook.com
 * @brief 链表的删除操作
 * @version 0.1
 * @date 2021-11-20
 *
 * @copyright Copyright (c) 2021
 *
 */
#include "list.h"

bool deleteNode(ListNode* linkedList, int data) {
  if (linkedList == nullptr) {
    return false;
  }
  ListNode* dummy = new ListNode(0, linkedList);
  while (dummy->next_) {
    if (dummy->next_->data_ == data) {
      ListNode* target = dummy->next_;
      dummy->next_ = dummy->next_->next_;
      delete target;
      return true;
    }
    dummy = dummy->next_;
  }
}
